﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TravelAgency.DAL;

namespace TravelAgency.AspNet.Users
{
    public partial class CancelReservation : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void LinkButtonNo_Click(object sender, EventArgs e)
        {
            this.Response.Redirect("~/Users/MyReservations.aspx");
        }

        protected void LinkButtonYes_Click(object sender, EventArgs e)
        {
            int reservationId = int.Parse(this.Request.QueryString["reservationId"]);

            TravelAgencyDAO dao = new TravelAgencyDAO();
            using (dao)
            {
                dao.CancelReservationByReservationId(reservationId);
                dao.SaveChanges();
            }

            this.Response.Redirect("~/Users/ReservationCanceled.aspx");
        }
    }
}